<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        html,
        body,
        #map {
            width: 100%;
            height: 100%;
            padding: 0;
            margin: 0
        }
        /* 隐藏图标 */
        
        .anchorBL,
        .BMap_cpyCtrl {
            display: none;
        }
        /* 不影响缩放组件的显示-BMAP_ANCHOR_BOTTOM_LEFT	控件将定位到地图的左下角 */
        /* .BMap_stdMpZoom {
            display: block;
        } */
    </style>
</head>

<body>
    <div id="map"></div>
    <script>
        /* 文档中有坐标拾取器功能--可以直接获取坐标 */
        function init() {
            var map = new BMapGL.Map('map', {
                minZoom: 8,
                maxZoom: 12,
                mapType: BMAP_NORMAL_MAP
            });
            var point = new BMapGL.Point(116.404, 39.915);
            map.centerAndZoom(point, 10); // 缩放
            map.enableScrollWheelZoom(true); // 滑轮可滚动
            map.setHeading(0); // 旋转角度
            map.setTilt(0); //倾斜角度
            // 3d地图
            // map.setMapType(BMAP_NORMAL_MAP); // 3d卫星图BMAP_EARTH_MAP,属性MapTypeId  ，街道地图BMAP_NORMAL_MAP
            // 添加控件
            var zoomCtrl = new BMapGL.ZoomControl({
                // 调整组件位置
                anchor: BMAP_ANCHOR_TOP_LEFT,
                // 位移
                offset: new BMapGL.Size(100, 10)
            });
            map.addControl(zoomCtrl); // 添加缩放组件
            // 监听缩放事件-地图更改缩放级别开始时触发触发此事件
            map.addEventListener('zoomstart', function() {
                console.log(map.getZoom());
            })
            map.addEventListener('zoomend', function() {
                console.log(map.getZoom());
            });
            // 显示距离控件
            var scaleCtrl = new BMapGL.ScaleControl({
                anchor: BMAP_ANCHOR_TOP_LEFT
            })

        }
        window.onload = function() {
            var script = document.createElement('script');
            script.src = 'https://api.map.baidu.com/api?type=webgl&v=1.0&ak=密匙C&callback=init'
            document.body.appendChild(script)
        }
    </script>
</body>

</html>